package com.gxa.employment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gxa.employment.entity.dto.ResumeStuDto;
import com.gxa.employment.entity.pojo.StuResume;
import com.gxa.employment.entity.vo.PageVo;
import com.gxa.employment.mapper.StuResumeMapper;
import com.gxa.employment.service.StuResumeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-03-28
 */
@Service
public class StuResumeServiceImpl extends ServiceImpl<StuResumeMapper, StuResume> implements StuResumeService {


//    简历的筛选操作
    @Override
    public PageVo<StuResume> select(ResumeStuDto resumeDto ) {
//      这里要进行分页查询，还要进行模糊查询
        LambdaQueryWrapper<StuResume> stuResumeLambdaQueryWrapper = Wrappers.lambdaQuery(StuResume.class);
//        模糊查询的条件
        stuResumeLambdaQueryWrapper.like(StringUtils.isNotEmpty(resumeDto.getStuMajor()),StuResume::getStuMajor,resumeDto.getStuMajor())
                .like(StringUtils.isNotEmpty(resumeDto.getClazzName()),StuResume::getClazzName,resumeDto.getClazzName())
                .like(resumeDto.getResExperienceYear()!=null,StuResume::getResExperienceYear,resumeDto.getResExperienceYear())
                .like(StringUtils.isNotEmpty(resumeDto.getStuName()),StuResume::getStuName,resumeDto.getStuName())
                .isNotNull(StuResume::getResFileName);
//        分页操作
        IPage<StuResume> page =new Page<>(resumeDto.getPage(),resumeDto.getSize());
        page(page,stuResumeLambdaQueryWrapper);
        List<StuResume> records = page.getRecords();
        long total = page.getTotal();
        PageVo<StuResume> pageVo = new PageVo<>(total,records);
        return pageVo;
    }
}
